package org.lord.slark.numbers.application;

import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;

import org.lord.slark.numbers.utils.LocalConstants;

public class LocalApplication extends Application {

    public static boolean isLocked = false;
    public String password = "1";
    ShepherdLockScreenReceiver receiver;
    IntentFilter filter;
    private SharedPreferences mSp;

    @Override
    public void onCreate() {
        super.onCreate();
        mSp = getSharedPreferences(LocalConstants.SP_NAME, Context.MODE_PRIVATE);
        //isLocked = mSp.getBoolean("applock", false);
        receiver = new ShepherdLockScreenReceiver();
        filter = new IntentFilter();
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        this.registerReceiver(receiver, filter);
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        this.unregisterReceiver(receiver);
    }

    class ShepherdLockScreenReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
                //isLocked = true;
            }
        }
    }
}
